﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Alos.Common;
using Alos.Entity;
using Alos.IService;
using Newtonsoft.Json;
using System.Threading.Tasks;

namespace Alos.LanClass.Api
{
    /// <summary>
    /// 学生提交记录表
    /// </summary>
    public class ReSubmitRecordController : ApiController
    {        
        IReSubmitRecordService ReSubmitRecordService;       
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_IReSubmitRecordService"></param>       
        public ReSubmitRecordController(IReSubmitRecordService _IReSubmitRecordService)
        {
            ReSubmitRecordService = _IReSubmitRecordService;            
        }
        /// <summary>
        /// 添加学生提交记录
        /// <param name="reSubmitRecord">学生提交记录</param>
        /// </summary>
        [HttpPost]
        [Route("api/ReSubmitRecord/CreateReSubmitRecord")]
        public JsonRtn<dynamic> CreateReSubmitRecord([FromBody]ReSubmitRecord reSubmitRecord)
        {
            var jsRtn = new JsonRtn<dynamic>();
            jsRtn.message = ReSubmitRecordService.CreateReSubmitRecord(reSubmitRecord) > 0 ? "true" : "false";
            return jsRtn;             
        }
        /// <summary>
        /// 修改学生提交记录
        /// <param name="data">学生提交记录(发布记录ID ArrangeID,资源ID ResourceID，学生ID StudentID)</param>
        /// </summary>
        [HttpPost]
        [Route("api/ReSubmitRecord/UpdateReSubmitRecord")]
        public JsonRtn<dynamic> UpdateReSubmitRecord([FromBody]ReSubmitRecord data)
        {
            var jsRtn = new JsonRtn<dynamic>();
            jsRtn.message = ReSubmitRecordService.UpdateSubmitRecord(data.ArrangeID.ToString(), (int)data.ResourceID, (int)data.StudentID) ? "true" : "false";
            return jsRtn;             
        }      
    }
}
